package com.cy.teducommunitys.com.cy.service.impl;

import com.cy.teducommunitys.com.common.annotation.RequiredLog;
import com.cy.teducommunitys.com.common.utils.IPUtils;
import com.cy.teducommunitys.com.cy.entity.Syslog;
import com.cy.teducommunitys.com.cy.entity.User;
import com.cy.teducommunitys.com.cy.mapper.SyslogMapper;
import com.cy.teducommunitys.com.cy.service.ISyslogService;
import lombok.extern.slf4j.Slf4j;
import org.apache.shiro.SecurityUtils;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.Signature;
import org.aspectj.lang.reflect.MethodSignature;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.lang.reflect.Method;
import java.util.Arrays;
import java.util.Date;

/**
 * <p>
 * 系统日志表 服务实现类
 * </p>
 *
 * @author mdzz
 * @since 2019-07-19
 */
@Service
@Slf4j
public class SyslogServiceImpl extends BaseServiceImpl<Syslog> implements ISyslogService {
    private SyslogMapper mapper;
    @Autowired
    public SyslogServiceImpl(SyslogMapper mapper) {
        super(mapper);
        this.mapper = mapper;
    }

    @Transactional(propagation = Propagation.REQUIRES_NEW)
    @Async
    @Override
    public void saveObject(Syslog sysLog) {
        log.info("Async thread pool:"+Thread.currentThread().getName());
        try {
            mapper.insert(sysLog);
        }catch(Exception e) {
            e.printStackTrace();
            log.info("插入日志失败");
        }
    }
}
